<template>
  <div class="edit">
    <h1>{{id?'编辑':'新建'}}分类</h1>
    <el-form label-width="120px">
      <el-form-item label="名称">
        <el-input v-model="model.name"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" native-type="submit" @click="save">保存</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  components: {},
  props: {
    id: {}
  },
  data() {
    return {
      model: {}
    };
  },
  computed: {},
  methods: {
    async save() {
      console.log(111);
      const res = await this.$http.post("/admin/api/categories", this.model);
      this.$router.push("/category/list");
      this.$message({
        type: "success",
        message: "保存成功"
      });
    }
  }
};
</script>

<style scoped>
</style>